package cn.e2win.biz.notice;

import java.sql.SQLException;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.e2win.base.entity.BaseEntity;
import cn.e2win.base.json.vo.Pager;
import cn.e2win.biz.base.BaseDAOHibernateImpl;
import cn.e2win.biz.dbo.DsEmp;


@Repository
public class NoticeDaoImpl extends BaseDAOHibernateImpl implements NoticeDao {
	String entitySql_DsEmp = "SELECT * FROM ("
			
			+ " SELECT t0.*"
			+ " FROM notice t0 "
			
			+ ") t "
			+ " WHERE 1=1 "
			+ " ORDER BY readStatus DESC, id DESC";
	
	
	
	@Override
	public void pagerNotice(Pager pager) {
		try {
			pager.processSql(entitySql_DsEmp);
			processPager(pager);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public Map<String, Object>getEntity(BaseEntity entity){
		if(entity instanceof DsEmp){
			return super.get1stRecordBySql(entitySql_DsEmp + " AND id=" + entity.getId(), null);
		}else{
			return super.getEntity(entity);
		}
	}
}
